package com.intretech.umsin.oss.config;


import com.intretech.umsin.oss.util.huaweiobs.HuaweiOssProperties;
import com.intretech.umsin.oss.util.huaweiobs.ObsTemplate;
import com.obs.services.ObsConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version V1.0
 * @ClassName: HuaweiOssConfig
 * @Description: HuaweiOssConfig 服务实现
 * @author: 李启联
 * @date: 2022-04-25 16:31
 * @Copyright: Copyright (c) 2022
 */
@Configuration
@ConditionalOnProperty(name = "oss-type",havingValue = "HUAWEI",matchIfMissing = false)
public class HuaweiOssConfig {

    @Autowired
    private HuaweiOssProperties obsProperties;

    @Bean
    public ObsTemplate obsTemplate(){
        ObsConfiguration config = new ObsConfiguration();
        config.setSocketTimeout(30000);
        config.setConnectionTimeout(30000);
        config.setEndPoint(obsProperties.getEndPoint());
        return new ObsTemplate(obsProperties.getBucketName(), obsProperties.getBucketLoc(), obsProperties.getSignedUrlExpires(),config);
    }

}
